<script setup lang="ts">
import { ref,reactive } from 'vue'
import type { TabsPaneContext } from 'element-plus'
import Audio from '@/views/Pu/Audio.vue'
import { useRouter } from 'vue-router';
import AllClass from '@/views/Pu/AllClass.vue'
import { RouterLink } from 'vue-router';
import { useRoute } from 'vue-router';
// 转换时间
import { getHMS } from "@/utils/time";

// TeacherDetail的数据
import {TeacherStore} from '@/stores/qianTaiPu/teacherDetailData'
import { onMounted } from 'vue';

// 最新发布课程
import {NewOpenCourse} from '@/api/Pu/qianTaiPu'
const store=TeacherStore()
const router=useRouter()
const route=useRoute();
const activeName = ref('first')

// 获取数据
onMounted(()=>{
  init()
  
   // 存id进入store
   console.log(route.query.id);
  store.Teaid=route.query.id
  
})
const init=()=>{
  // 最新发布课程
  NewOpenCourse(store.Teaid).then((resp)=>{
  // NewOpenCourse(1).then((resp)=>{
     console.log(resp.data.data);
    store.NewOpen=resp.data.data
     console.log(store.NewOpen);
     
  })

}


// 更多按钮
const More=()=>{
  // console.log(router);
    router.push('/TeachersDetail/MoreButton')
}

</script>
<template>
  <div class="MaxBox">
<div class="Box">
<h2>Ta的课程</h2>
<el-tabs v-model="activeName" class="demo-tabs KeCheng"  >
    <el-tab-pane label="最新发布" name="first">
      <!-- 最新发布 -->
        <div class="course">
          <RouterLink to="/FrontFreeClass" v-for="item in store.NewOpen" >
          <Audio  :price="item.price" :enlists_num="item.enlistsNum" :recent_num="item.recentNum" :create_time="(getHMS(item.createTime).slice(5,10))" :class_name="item.className" :src="item.img"></Audio>
        </RouterLink>
        </div>
        <div class="produce">
          <h3>Ta的介绍</h3>
          <!-- 判断Ta的介绍-->
          <template v-if="store.TeacherData[0].synopsis ==undefined">
          <p>无</p>
        </template>
        <template v-else>
         <p>{{ store.TeacherData[0].synopsis }}</p>
        </template>
        </div>
      </el-tab-pane>
    <el-tab-pane label="最多报名" name="second">最多报名</el-tab-pane>
    <el-tab-pane label="最新收藏" name="third">最新收藏</el-tab-pane>
  </el-tabs>
  <el-button  round @click="More" class="MoreButton">更多 ></el-button>
</div>

<div width="300px">
  <AllClass></AllClass>
</div>
</div>
</template>
<style scoped>
*{
    margin: 0;
    padding: 0;
    list-style: none;
}
.MaxBox{
  width: 100%;
  display: flex;
}
.Box{
  display: flex;
height: 100px;
align-items: center;
width:1000px;
}

.course{
  width: 900px;
}
h2{
    margin-left: 30px;
}
.el-tabs{
margin-left: 70px;
width: 29%;
}
.more{
  margin-left: auto;
}

/*最新发布  */
/* 视频栏 */
:deep(.el-tabs__content){
position:absolute !important;
left:70px;
width: 900px;
}
.el-tab-pane {
    display: flex;
    flex-wrap: wrap;
}
.el-tab-pane .img{
  width: 22%;
}
:deep(.demo-tabs > .el-tabs__content ){
  margin-left:-90px  ;
}
.MoreButton{
  margin-left: 380px;
}
/* Ta的介绍 */
.produce{
  font-size: 18px;
  width: 1000px;
  height: 500px;
  color: black;
  text-align: left;
  margin-top: 50px;
}
.produce h3{
  margin-left: 10px;
}
.produce p {
   font-size: 16px; 
   display: block;
  margin-left: 35px;
  margin-top: 30px;
}
</style>